home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94c.txt / 000036_icon-group-request _Sun Dec 25 05:56:46 1994.msg < prev    next >
Internet Message Format  |  1995-02-09  |  3KB

  1. Received: from optima.CS.Arizona.EDU by cheltenham.CS.Arizona.EDU; Sun, 25 Dec 1994 04:30:18 MST
  2. Received: from agate.Berkeley.EDU by optima.CS.Arizona.EDU (5.65c/15) via SMTP
  3.     id AA00527; Sun, 25 Dec 1994 04:30:16 MST
  4. Received: by agate.berkeley.edu (8.6.8.1/1.33)
  5.     id DAA11618; Sun, 25 Dec 1994 03:00:05 -0800
  6. Received: from GATEWAY by agate with netnews
  7.     for icon-group@cs.arizona.edu (icon-group-l@cs.arizona.edu)
  8. To: icon-group-l@cs.arizona.edu
  9. Date: 25 Dec 1994 05:56:46 -0500
  10. From: MENGARINI@news1.delphi.com (MENGARINI@DELPHI.COM)
  11. Message-Id: <3djj5e$7pd@news2.delphi.com>
  12. Organization: Delphi Internet Services Corporation
  13. Sender: icon-group-request@cs.arizona.edu
  14. Subject: DeMorgan's Law doesn't work
  15.  
  16. I needed to find the first filename of the form "w[0-9][0-9]" that was
  17. not in use in either of 2 directories.  This code
  18.    (  nn := (0 to 9) || (0 to 9)
  19.    ,  not exists( downloadDir || "w" || nn )
  20.    ,  not exists( targetDir   || "w" || nn )
  21.    )|stop( "No names of the form w[0-9][0-9] were unused." )
  22. works, but the separation of the 2 "not exists" calls is reminiscent
  23. of Algol-family languages' need to code things like
  24.    if importantNumber = 1 | importantNumber = 2
  25. where Snobol-family languages could just test whether
  26.    importantNumber = 1 | 2
  27. Analogously, Icon should be able to factor out the 2 "not exists" calls.
  28.  
  29. But this
  30.    (  nn := (0 to 9) || (0 to 9)
  31.    ,  not exists( (downloadDir|targetDir) || "w" || nn )
  32.    )|stop( "No names of the form w[0-9][0-9] were unused." )
  33. doesn't work because DeMorgan's Law doesn't work:
  34. if downloadDir || "w" || nn doesn't exist, exists() fails, not exists()
  35. succeeds, & the expression succeeds, without ever testing whether
  36. targetDir || "w" || nn exists.
  37.  
  38. So far, this
  39.    (every nn := (0 to 9) || (0 to 9) do {
  40.       (exists( (downloadDir|targetDir) || "\\w" || nn ), next) | break
  41.    })|stop( "No names of the form w[0-9][0-9] were unused." )
  42. is the best I can do, but I dislike it because it makes use of a very
  43. obscure aspect of break; Griswold & Griswold 1990 p19 doesn't even mention
  44. it, altho it's in Appendix C on p285. (BTW, p19 seems to imply incorrectly
  45. that break only works with while & until, even tho every was introduced on
  46. p16; & Appendix C doesn't clarify this.)
  47.  
  48. Can anybody suggest a more elegant expression?
  49.  
  50. Can anybody suggest a language extension that would help?
  51.  
  52.             "Software is neither science nor engineering.
  53.              It's really an obscure form of poetry."
  54.                   --Dirk Zoller
  55.  
  56. Will Mengarini  <mengarini@delphi.com>  Hey, at least it's not AOL
  57.